# -*- coding: utf-8 -*-
import codecs
# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: http://doc.scrapy.org/en/latest/topics/item-pipeline.html


class DangdangPipeline(object):
    def __init__(self):
        self.write = codecs.open('book_list.txt','w',encoding='utf-8')

    def process_item(self, item, spider):
        name = item['title']
        num = item['num']
        print (name, num)
        print ('-------------')
        self.write.write('{}、{} \n'.format(num,name))
        return item

